package com.example.definedview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.example.definedview.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {
    ActivityMainBinding activityMainBinding;
    int percent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        activityMainBinding.panView.setMaxNum(500);
        activityMainBinding.panView.setStartNum(0);
        activityMainBinding.panView.setUnit("g");
        activityMainBinding.panView.setTextSize(20);
        percent = 0;
        activityMainBinding.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(percent<100){
                    percent += 2;
                }

                activityMainBinding.panView.setPercent(percent);
            }
        });

        activityMainBinding.button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(percent > 0){
                    percent -= 2;
                }
                activityMainBinding.panView.setPercent(percent);
            }
        });

        activityMainBinding.toChart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ChartActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toHello.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,HelloActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toSchedule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ScheduleActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toState.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,StateActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toStop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,StopActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toTemperature.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,TemperatureActivity.class);
                startActivity(intent);
            }
        });

        activityMainBinding.toTime.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,TimeActivity.class);
                startActivity(intent);
            }
        });
    }
}
